/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import React from 'react';
import { Popconfirm } from 'antd';
import type { ProColumns, ActionType } from '@ant-design/pro-table';
import type { CloudBlack } from './index.d';
import { moveOutBlack } from './utils';

const getColumns = (actionRef: ActionType | any) => {
  const cloumns: ProColumns<CloudBlack>[] = [
    {
      title: '',
      dataIndex: 'username',
      align: 'center',
      hideInTable: true,
      fieldProps: {
        placeholder: '请输入手机号搜索',
      },
    },
    {
      title: '',
      dataIndex: 'cmId',
      align: 'center',
      hideInTable: true,
      fieldProps: {
        placeholder: '请输入cm_id',
      },
    },
    {
      title: '序号',
      dataIndex: 'bid',
      align: 'center',
      search: false,
    },
    {
      title: '账号',
      dataIndex: 'courier_tel',
      align: 'center',
      search: false,
    },
    {
      title: '平台标识',
      dataIndex: 'brand',
      align: 'center',
      search: false,
      render: (_, record) => {
        return record.brand == 'dak' ? '驿站' : '快递员';
      },
    },
    {
      title: '操作人',
      dataIndex: 'operator',
      align: 'center',
      search: false,
    },
    {
      title: '拉黑原因',
      dataIndex: 'note',
      align: 'center',
      search: false,
    },
    {
      title: '拉黑时间',
      dataIndex: 'time',
      align: 'center',
      search: false,
    },
    {
      title: '操作人',
      valueType: 'option',
      align: 'center',
      search: false,
      render: (_, record) => {
        return (
          <Popconfirm
            title='你确定取消拉黑吗？'
            onConfirm={moveOutBlack.bind(null, record, actionRef)}
          >
            <a>取消拉黑</a>
          </Popconfirm>
        );
      },
    },
  ];
  return cloumns;
};

export { getColumns };
